﻿namespace Furesoft.Styling.Design
{
    using System.Drawing;

    using FastColoredTextBoxNS;

    public class UnderlineStyle : FastColoredTextBoxNS.Style
    {
        private readonly Pen color;

        public readonly int icon;

        public UnderlineStyle(Pen color, int icon)
        {
            this.color = color;
            this.icon = icon;
        }

        public UnderlineStyle(Pen color)
        {
            this.color = color;
        }

        public override void Draw(Graphics gr, Point position, Range range)
        {
            //get size of rectangle
            var size = GetSizeOfRange(range);
            //create rectangle
            var rect = new Rectangle(position, size);

            gr.DrawLine(color, rect.X, rect.Y + rect.Height-1, rect.X + rect.Width, rect.Y + rect.Height-1);
            gr.DrawLine(color, rect.X, rect.Y + rect.Height, rect.X + rect.Width, rect.Y + rect.Height);
        }

        public override string ToString()
        {
            return color.Color.Name;
        }
    }
}